package ru.spb.osll.myfit.util;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;

public class IOUtils {
	public static List<String> readLines(BufferedReader reader) throws IOException {
		LinkedList<String> lines = new LinkedList<String>();
		String line = reader.readLine();
		while (line != null) {
			lines.add(line);
			line = reader.readLine();
		}

		return lines;
	}

	private IOUtils() {
	}
	
	public static List<String> readFile(String fileName) throws IOException {
	  List<String> lines = new LinkedList<String>();
	  FileInputStream stream = null;
    try {
      stream = new FileInputStream(fileName);
      BufferedReader inStream = new BufferedReader(
          new InputStreamReader(stream));
      lines = readLines(inStream);
      inStream.close();
      
    } finally {
      // LOG.debug("file don't exist in finally");
      if (stream != null)
        stream.close();
    }
    return lines;
	}
}
